require(['init'], function () {
  function Agencyinformation() {
    $("input").focus(function () {
        $('#J_enroll_submit').attr("disabled", false);
    });
    $.ajax({
        url: '/api/system/config',
        type: 'get',
        success: function (data) {
            $('#J_enroll_submit').attr("disabled", "disabled");
            $('[name=defaultpassword]').val(data.data.defaultpassword);
            $('[name=checkteachertime]').val(data.data.checkteachertime);
            if(data.data.checkteachertime==1){
              $('[name=checkteachertime]').click();
            }
        }
    })
    //点击保存
    $("#J_enroll_submit").on("click", function () {
        var defaultpassword = $('[name=defaultpassword]').val();
        var checkteachertime = $('[name=checkteachertime]').prop('checked') ? 1: 0;
        var arr = {
            "defaultpassword": defaultpassword,
            "checkteachertime": checkteachertime
          }
        var popUpBox = new PopUpBox({
            type: 'dom',
            style: 'default contentScroll',
            submitBtnType: 'confirm',
            titleText:i18next.t('popupbox.warmprompt'),//温馨提示
            show: true,
            content: '<div style="margin-left:27px;margin-top:34px;">'+i18next.t('popupbox.oksave')+'</div>',//确定要保存吗?
            callback: {
                yes: function (e) {
                    ajaxMethod({
                        url: '/api/system/config',
                        data: arr,
                        type: 'post',
                        success: function (data,status) {
                            if(status.code!=0){
                              var popUpBox = new PopUpBox({
                                  type: 'dom',
                                  style: 'default contentScroll',
                                  submitBtnType: 'alert',
                                  titleText:i18next.t('popupbox.warmprompt'),//温馨提示
                                  show: true,
                                  content: '<div style="margin-left:27px;margin-top:34px;">'+status.message+'!</div>',
                                  callback: {
                                      yes: function (e) {
                                      }
                                  },
                                  position: {
                                      width: 448,
                                      height: 226
                                  }
                              })
                              $(".submitBtnBox").find('.btn').css('margin-left','283px')
                            }else{
                              var popUpBox = new PopUpBox({
                                  type: 'dom',
                                  style: 'default contentScroll',
                                  submitBtnType: 'alert',
                                  titleText:i18next.t('popupbox.warmprompt'),//温馨提示
                                  show: true,
                                  content: '<div style="margin-left:27px;margin-top:34px;">'+i18next.t('info.savesuccessfully')+'!</div>',
                                  callback: {
                                      yes: function (e) {
                                        window.location.reload();
                                      }
                                  },
                                  position: {
                                      width: 448,
                                      height: 226
                                  }
                              })
                              $(".submitBtnBox").find('.btn').css('margin-left','283px')
                            }
                        }
                    })
                }
            },
            position: {
                width: 448,
                height: 226
            }
        })

    })
    }

    Agencyinformation();


})
